﻿using MediatR;
using T_Rbac.Read.APi.Application.Command.Dapartments;
using T_Rbac_Demain;
using T_Rbac_Rep.Interface;

namespace T_Rbac.Read.APi.Application.Handlers
{
    public class DepartmentSearchByPidCommandHandlers : IRequestHandler<DapartmentSearchByDidCommand, IQueryable<Dapartment>>
    {
        private readonly IDapartment dapartment;
        /// <summary>
        /// 构造函数注入
        /// </summary>
        /// <param name="dapartment"></param>
        public DepartmentSearchByPidCommandHandlers(IDapartment dapartment)
        {
            this.dapartment = dapartment;
        }

        public async Task<IQueryable<Dapartment>> Handle(DapartmentSearchByDidCommand request, CancellationToken cancellationToken)
        {
            var list = await dapartment.GetvaluesByResult(x => x.Dpid.Equals(request.pid));
            return list;
        }
    }
}
